[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
exp() Calculate Exponential
#include <math.h>
double exp(x);
double x; Floating-point value
exp() returns the exponential function of 'x'.
Returns: Exponential function of 'x'. On overflow, matherr()
is called with an OVERFLOW error, errno is set to
ERANGE (defined in <errno.h>), and the value HUGE_VAL
(defined in <math.h>) is returned. On underflow 0.0
is returned. (matherr() is not called on an
underflow, and 'errno' is not set.)
Notes: Error handling can be modified with the matherr()
routine.
OVERFLOW first occurs with 'x' greater than 7.0E2.
-------------------------------- Example ---------------------------------
The following statements continue printing the exponential function
of the values in an array until an OVERFLOW error occurs.
#include <math.h> /* for exp() */
#include <stdio.h> /* for printf() */
#include <errno.h> /* for errno and ERANGE*/
/* the value 1000.0 will cause an error */
double values[6] = {0.0, 1.0, -1.0, -500, 1000.0, -0.2};
main()
{
double exponential;
int i;
errno = 0;
for (i = 0; !errno && i < 6; i++) {
exponential = exp(values[i]);
if (errno == ERANGE) /* error is also printed to stderr */
printf("OVERFLOW error in exp()\n");
printf("exponential function of %f = %f\n",
values[i], exponential);
}
}
See Also:
log()
log10()
matherr()
pow()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson